<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="${ctx}/styles/gsjcss/common.css">
<title>国省自检--${fns:getConfig('productName')}</title>
<script type="text/javascript">
	function btnClick(){
		var url = '${ctx}/repair/search.do?projectId=${fns:encodeParamUrl(projectId)}&menuId=${fns:encodeParamUrl(menuId)}';
		var data = {};
		if($('#btnSearch').length>0){ //有搜索按钮的情况下 获取条件进行搜索
			data['retrieval'] = getJson('condition');
			loadData(url,data);
		} else {
			loadData(url,data);
		}
	}
	//ajax执行成功之后的回调方法
	function loadDataToTable(data){
		var attData = data['att'];
		var manageData = data['manageData'];
		loadAttachment(attData);
		for(var j = 0; j<manageData.length;j++ ){
			var tr = "<tr><td>"+$("#manageData tr").length+"</td><td>"+manageData[j].manageOrg+"</td><td>"+manageData[j].bullentinYear+"</td><td>";
			if(manageData[j].bulletinNumber > 0){
				tr +="<img src='${ctx}/images/right.jpg";
			} else {
				tr +="<img src='${ctx}/images/error.jpg";
			}
			tr+="' style='width:20px;height:20px'></td></tr>";
			$("#manageData tbody").append(tr);
			var  attData = manageData[j].attachments;
			for(var i = 0; i<attData.length;i++ ){
				var tr ="<tr><td>"+$('#'+attData[i].tag+" tr").length+"</td><td><a href='${ctx}/attachment/download.do?attId="+attData[i].id+"'>下载</a></td><td>"+attData[i].fileOrg+"</td><td>"+attData[i].uploadPerson+"</td>"+
				"<td><a href='${ctx}/documentView.jsp?fileName="+attData[i].upfileFileName+"&swfPath="+attData[i].swfPath+"' target='_blank'>"+attData[i].upfileFileName+"</a></td><td>"+attData[i].fileTime+"</td><td>"+attData[i].createDate+"</td><td>"+attData[i].size+"</td><td>"+attData[i].type+"</td></tr>";
				$('#'+attData[i].tag+" tbody").append(tr);
			}
		}
		//当返回的数据包含年份信息时，说明是根据某个单位进行了查询  显示该单位的检查结果
		if(data['sum'] != undefined){
			var years = data['years'];
			var detectionResult = data['timeResult'];
			var content = '<table style="width:98%;text-align:center;margin-top:5px;" border="1"><thead><tr>'+
// 								'<th rowspan="2">序号</th>'+
								'<th rowspan="2">管养单位</th>';
			var stage="";
			for(var i =0;i<years.length;i++){
				content += '<th colspan="2">'+years[i]+'</th>';
				stage+='<th>上半年</th><th>下半年</th>';
			}
			content += '<th rowspan="2">检查得分</th><th rowspan="2">完善度</th></tr>'+
						'<tr>'+stage+'</tr></thead><tbody></tbody></table>';
			$('#checkResult').append(content);
			var tr ='<tr><td>'+$('#manageOrg').find('option:selected').text()+'</td>';
			for(var i =0; i<detectionResult.length;i++){
				if(detectionResult[i] == 1){
					tr +="<td>"+imgRight+"</td>";
				} else {
					tr +="<td>"+imgError+"</td>";
				}
			}
			tr+='<td class="sumTd">'+data['sum']+'</td><td class="perTd">'+data['percent']+'%</td></tr>';
			$('#checkResult tbody').append(tr);
		}
	}
</script>
</head>
<body>
	<div id="x_top"></div>
	<tags:message content="${msg}" />
	<c:if test="${not empty checkTable.id}">
		<div style="text-align:center">
			<a href="javascript:void(0);" class="btn btn-primary" onclick="downWord('${ctx}/repair/downWord.do?projectId=${fns:encodeParamUrl(projectId)}&menuId=${fns:encodeParamUrl(menuId)}');" id= "btnDown" role="button" ><div id="x_v"></div></a>
		</div>
	</c:if>
	<form id="checkForm" class="form-horizontal"  method="POST"  name="checkForm" action="${ctx}/repair/save.do?left=${fns:encodeParam(left)}&top=${fns:encodeParam(top)}&projectId=${fns:encodeParam(projectId)}&menuId=${fns:encodeParam(menuId)}&leftChild=${fns:encodeParam(leftChild)}">
		<input type="hidden" name="token" value="${token}">
		<div id="show">
			<div id="showTable" class="showTable">
				<jsp:include page="/WEB-INF/views/check/common.jsp"/> 
				<div class="model">
					<div>
						<legend>三、检查条件及设置</legend>
						<div class="content-title" id="condition">
							<div style="float:left;margin-right:10px;">
								<span>养护检查记录:</span>
								<select name="manageOrg" id="manageOrg" style="width:130px;padding-left:0px;padding-right:0px;">
									<option value=""></option>
									<c:forEach items="${fns:getMainBulletinsGroupByManageOrg()}" var="mainBulletin"  varStatus="idxStatus">
										<option value="${mainBulletin.manageOrg}">${mainBulletin.manageOrg}</option>
									</c:forEach>
								</select>
							</div>
							<div style="float:left;">
								<span>有两次检查记录分数<font style="color:red;">*</font>：</span>
								<input type='text' name = "yearFull" id="yearFull" value="0.15" class="required conInput"/>
								<span>有一次检查记录分数<font style="color:red;">*</font>：</span>
								<input type='text' name = "yearPart" id="yearPart" value="0.1" class="required conInput"/>
							</div>
							<div id="x_s" style="float:right"  onclick= "btnClick()">
								<div class="x_ico"></div>
								<a id= "btnSearch" role="button" >搜索&nbsp;</a>
							</div>
						</div>
					</div>
				</div>
				<div class="model">
					<div>
						<legend>四、检索结果</legend>
						<div class="content-title">
							<div class="tabbox">
								<div class="tab">
									<a href="javascript:;" class="on">养护检查记录</a>
									<c:forEach items="${childMenuList}" var="menu"  varStatus="idxStatus">
										<c:if test="${idxStatus.index >= 2}">
											<a href="javascript:;">${menu.name}</a>
										</c:if>
									</c:forEach>
							    </div>
							    <div class="content">
							    	<ul>
							    		<li>
						    				<table style="width:98%;text-align:center;margin-top:5px;" border="1" id="manageData">
						    					<thead>
							    					<th>序号</th>
							    					<th>管养单位</th>
							    					<th>检查时间</th>
							    					<th>已上传通报/整改文件</th>
						    					</thead>
						    					<tbody>
						    						
						    					</tbody>
						    				</table>
								    	</li>
							    		<c:forEach items="${childMenuList}" var="menu"  varStatus="idxStatus">
							    			<c:if test="${idxStatus.index >= 2}">
								    			<li>
								    				<table style="width:98%;text-align:center;margin-top:5px;" border="1" id="${menu.tag}">
								    					<thead>
									    					<th>序号</th>
									    					<th>操作</th>
									    					<th>发文单位</th>
									    					<th>上传用户</th>
									    					<th>文件名</th>
									    					<th>发文日期</th>
									    					<th>上传日期</th>
									    					<th>文件大小</th>
									    					<th>文件类型</th>
								    					</thead>
								    					<tbody>
								    						
								    					</tbody>
								    				</table>
								    			</li>
								    		</c:if>
							    		</c:forEach>
							        </ul>
							    </div>
							</div>
						</div>
					</div>
				</div>
				<div class="model">
					<div>
						<legend>五、检查评分</legend>
						<div class="content-title" id="checkResult">
						
						</div>
					</div>
				</div>
				<div class="model">
					<div class="content-btn">
						<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存" />
						&nbsp;&nbsp;&nbsp;&nbsp;
						<input id="btnCancel" class="btn" type="button" value="返 回" onclick="toBack()" />
					</div>
				</div>
			</div>
		</div>
	</form>
	<script src="${ctxStatic}/js/check/checkCommon.js" type="text/javascript"></script>
</body>
</html>